<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Unity测试</title>

    <script>

        //用于外部调用云妹内部函数
        function callYm(params) {
            console.log("收到Unity数据响应:", params);
            alert("收到Unity数据响应:" + params)
        }


        function sendToUnity(action) {
            //如果当前没有处于unity环境中，则什么都不做
            if (!window.YmToUnity) {
                alert('当前不是unity环境')
                return
            }


            window.YmToUnity(action)


        }

        window.callYm = callYm;

    </script>


    <style>
        .content {
            height: 300px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 100px;
            color: white;
            background: pink;
        }

        .opt-btns{
            margin: 20px 0;
            display: flex;
            
            button{
                margin-right: 20px;
                font-size: 20px;
            }
        }

        .info{
            font-size: 20px;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div class="info">
        浏览器信息：<span class="user-agent"></span>
    </div>

    <div class="opt-btns">
        <button onclick="sendToUnity('start_think')">start_think</button>
        <button onclick="sendToUnity('end_think')">end_think</button>
        <button onclick="sendToUnity('start_speech')">start_speech</button>
        <button onclick="sendToUnity('end_speech')">end_speech</button>
    </div>
    <div class="content">
        这是云妹调试页面
    </div>

</body>

</html>


<script>
    // 显示浏览器信息
    document.querySelector('.user-agent').textContent = navigator.userAgent;
</script>